﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DAL
{
     public  class DangKiProvider
    {
         public static int ThemDangKi(DangKy dk)
         {
             int maDK = -1;
             try
             {
                 using (QLTTTHEntities context = new QLTTTHEntities())
                 {
                     context.DangKies.Add(dk);
                     context.SaveChanges();
                     maDK = dk.MaDangKy;
                 }
             }
             catch
             {

             }
             return maDK;
         }
         public static List<DangKy> LayDanhSachDangKy()
         {
             var lst = new List<DangKy>();
             using (var context = new QLTTTHEntities())
             {
                 var query = (from u in context.DangKies select u);

                 foreach (var row in query)
                 {
                     var dk = new DangKy();
                     dk.MaDangKy = row.MaDangKy;
                     dk.MaHV = row.MaHV;
                     dk.NgayDangKy = row.NgayDangKy;
                     dk.MaLop = row.MaLop;
                     dk.MaKH = row.MaKH;
                     dk.LoaiDangKy = row.LoaiDangKy;
                     lst.Add(dk);
                 }
             }
             return lst;
         }

    }
}
